program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  pelement= ^element;
  element=record
    next: pelement;
    val: integer;
  end;
procedure Add(var head: pelement; p: integer);
var
  tmp: pelement;
begin
  tmp:=head;
  new(head);
  head^.next:=tmp;
  head^.val:=p;
end;

procedure Print(var heads: pelement);
var
  current: pelement;
begin
  current:=heads;
  while (current<> nil) do
  begin
    writeln(current^.val);
    current:=current^.next;
  end;
end;

procedure AddSum(var heads: pelement; p: integer);
var
  tmp: pelement;
begin
  tmp:=heads;
  new(heads);
  heads^.next:=tmp;
  heads^.val:=p;
end;

procedure Turn(var head: pelement; n: integer);
var
  current, heads: pelement;
  i, p: integer;
begin
  heads:=nil;
  current:=head;
  for i:=1 to n-1 do
  begin
    p:=current^.val;
    AddSum(heads, p);
    current:=current^.next;
  end;
  p:=current^.val;
  AddSum(heads, p);
  Print(heads);
end;

var
  head: pelement;
  n: integer;
  p, i: integer;
  fin: textfile;
begin
  assignfile(fin, 'input.txt');
  reset(fin);
  head:=nil;
  readln(fin, n);
  for i:=1 to n do
  begin
    read(fin, p);
    Add(head, p);
  end;
  Turn(head, n);
  readln;
  closefile(fin);
end.
